package bch.maven.plugin.guava;

import com.google.common.collect.EnumMultiset;
import com.google.common.collect.Multiset;

public class EnumMultisetExample {
    enum Fruit { APPLE, BANANA, ORANGE }

    public static void main(String[] args) {
        Multiset<Fruit> basket = EnumMultiset.create(Fruit.class);
        basket.add(Fruit.APPLE);
        basket.add(Fruit.APPLE);
        basket.add(Fruit.BANANA);

        System.out.println("苹果数量：" + basket.count(Fruit.APPLE)); // 2
        System.out.println("所有水果及数量：" + basket); // [APPLE x 2, BANANA]
    }
}
